package com.jby.autotest.controller;

import com.alibaba.fastjson.JSONObject;
import com.jby.autotest.model.WholeProcess;
import com.jby.autotest.service.other.WholeProcessService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/wholeProcess")
public class WholeProcessController {

    private static final Logger logger = LogManager.getLogger(WholeProcessController.class);

    @Autowired
    private WholeProcessService wholeProcessService;

    @RequestMapping(value = "/saveWholeProcess")
    @ResponseBody
    public Map<String, Object> saveWholeProcess(WholeProcess wholeprocess){
        Date date = new Date();
        wholeprocess.setCreateTime(date);
        wholeprocess.setUpdateTime(date);

        logger.info("WholeProcessController-->saveWholeProcess-->request: " + JSONObject.toJSONString(wholeprocess));

        Map<String,Object> map = new HashMap<>();

        try{
            wholeProcessService.insertSelective(wholeprocess);
            logger.info("WholeProcessController-->saveWholeProcess-->response: " + "success");
            map.put("status","success");
        }catch (Exception e){
            logger.error("WholeProcessController-->saveWholeProcess: " + e);
            map.put("status","fail");
            return map;
        }
        return map;
    }






























}
